package com.xisoft.handle;

import com.xisoft.base.BaseModel;
import com.xisoft.common.ProcessorException;
import org.apache.commons.lang3.StringUtils;

import java.io.File;


/**
 * @author xzh
 * @Date 2021/8/16
 * @description 参数校验
 * 注意：本内容仅限于上海熙软科技有限公司内部，传阅，禁止外泄以及用于其他商业目的
 */
public class CheckHandler implements Handler {

    @Override
    public void handle(BaseModel model, HandlerChain chain) throws ProcessorException {

        if (StringUtils.isEmpty(model.tablename)) {
            throw new ProcessorException("您传入的表名【tablename】为空");
        }

        if (StringUtils.isEmpty(model.author)) {
            throw new ProcessorException("您传入的创建人【author】的值为空");
        }

        if (StringUtils.isEmpty(model.basePackageName)) {
            throw new ProcessorException("您传入包名【voPackageName】的值为空");
        }
        File basePath = new File(model.base_path);
        if (!basePath.exists()) {
            throw new ProcessorException("您配置的项目基础路径【model.base_path】不存在");
        }
        chain.handle(model);

    }

}
